﻿using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace EdlinSoftware.RegexTester.Controls
{
    public class RegexOptionsCheckedListBox : CheckedListBox
    {
        #region Methods

        public void ShowOptions()
        {
            Items.Clear();
            foreach (string regexOption in Enum.GetNames(typeof(RegexOptions)))
            {
                Items.Add(regexOption, false);
            }
        }

        public RegexOptions GetOptions()
        {
            RegexOptions result = RegexOptions.None;
            foreach (string regexOption in CheckedItems)
            {
                result |= (RegexOptions)Enum.Parse(typeof(RegexOptions), regexOption);
            }
            return result;
        }

        #endregion
    }
}
